﻿@using BoYuanCore.WebUI.Code
@{
    ViewBag.Title = "后台管理系统";
    var F = Html.F();
}

@section head {

    <link type="text/css" rel="stylesheet" href="~/res/css/index.css?v@(GlobalConfig.ProductVersion)" />
    <link type="text/css" rel="stylesheet" href="~/res/css/mobileview.css?v@(GlobalConfig.ProductVersion)" />

}

@functions {
    private void SetCheckedMenuItem(MenuButton menuButton, string checkedValue)
    {
        foreach (MenuItem item in menuButton.Menu.Items)
        {
            MenuCheckBox checkBox = (item as MenuCheckBox);
            if (checkBox != null)
            {
                checkBox.Checked = checkBox.AttributeDataTag == checkedValue;
            }
        }
    }
}


@section body {

    <div id="sideheader" class="f-widget-header f-mainheader">
        <a class="logo" href="@Url.Action("Index")" title="@ViewBag.Title">@ViewBag.Title</a>
    </div>

    <div id="header" class="f-widget-header f-mainheader" style="display:none;">
        <div class="header-left">
            @(F.Button().ID("btnCollapseSidebar").CssClass("icononlyaction").ToolTip("折叠/展开侧边栏").IconAlign(IconAlign.Top).IconFont(IconFont._Fold).EnableDefaultState(false).EnableDefaultCorner(false).TabIndex(-1).Listener("click", "onFoldClick"))
            <div id="breadcrumb">
                <div class="breadcrumb-inner">
                    <span class="breadcrumb-last">首页</span>
                </div>
                <div class="breadcrumb-icons">

                    <a data-qtip="刷新本页" href="javascript:onToolRefreshClick();"><i class="f-icon f-iconfont f-iconfont-refresh"></i></a>
                </div>
            </div>
        </div>
        <div class="header-right">
            @(F.Button().CssClass("icononlyaction").ID("btnThemeSelect").ToolTip("主题仓库").IconAlign(IconAlign.Top).IconFont(IconFont._Skin).EnableDefaultState(false).EnableDefaultCorner(false).TabIndex(-1).Listener("click", "onThemeSelectClick"))
            @(F.Button().EnableDefaultCorner(false).EnableDefaultState(false).IconAlign(IconAlign.Left).IconUrl(Url.Content(ViewBag.UserShowHead)).Text(ViewBag.UserShowName).CssClass("userpicaction")
                .Menu(F.Menu()
                    .Items(

                        F.MenuButton().Text("显示模式").ID("MenuDisplayMode").Hidden(ViewBag.CookieIsBase || ViewBag.CookieShowOnlyBase)
                            .Menu(F.Menu()
                                .Items(
                                    F.MenuCheckBox().GroupName("DisplayMode").AttributeDataTag("compact").ID("MenuDisplayModeCompact").Text("紧凑模式"),
                                    F.MenuCheckBox().GroupName("DisplayMode").AttributeDataTag("small").ID("MenuDisplayModeSmall").Text("小字体模式"),
                                    F.MenuCheckBox().GroupName("DisplayMode").Checked(true).AttributeDataTag("normal").ID("MenuDisplayModeNormal").Text("普通模式"),
                                    F.MenuCheckBox().GroupName("DisplayMode").AttributeDataTag("large").ID("MenuDisplayModeLarge").Text("大字体模式"),
                                    F.MenuCheckBox().GroupName("DisplayMode").AttributeDataTag("largeSpace").ID("MenuDisplayModeLargeSpace").Text("大间距模式")
                                ).Listener("checkchange", "onMenuDisplayModeCheckChange")
                            ),
                        F.MenuButton().ID("MenuStyle").Text("菜单样式").Hidden(ViewBag.CookieIsBase || ViewBag.CookieShowOnlyBase)
                            .Menu(F.Menu()
                                .Items(
                                    F.MenuCheckBox().GroupName("MenuStyle").Checked(true).AttributeDataTag("tree").ID("MenuStyleTree").Text("智能树菜单"),
                                    F.MenuCheckBox().GroupName("MenuStyle").AttributeDataTag("plaintree").ID("MenuStylePlainTree").Text("树菜单")
                                ).Listener("checkchange", "onMenuStyleCheckChange")
                            ),
                            F.MenuButton().Icon(Icon.UserEdit).Text("个人编辑").Listener("click", "onWindowEditClick"),
                            F.MenuButton().ID("MenuLogout").Text("安全退出").Icon(Icon.CupGo).ConfirmText("确定退出系统？").OnClick(@Url.Action("Logout")),
                            F.MenuButton().ID("MenuMainTabs").Text("主选项卡标签")
                                .Menu(F.Menu()
                                    .Items(
                                        F.MenuCheckBox().GroupName("MenuMainTabs").Checked(true).AttributeDataTag("multi").ID("MenuMainTabsMulti").Text("多标签页"),
                                        F.MenuCheckBox().GroupName("MenuMainTabs").AttributeDataTag("single").ID("MenuMainTabsSingle").Text("单标签页")
                                    ).Listener("checkchange", "onMenuMainTabsCheckChange")
                            )
                    //F.MenuButton().ID("MenuLang").Text("语言")
                    //    .Menu(F.Menu()
                    //        .Items(
                    //            F.MenuCheckBox().GroupName("MenuLang").Checked(true).AttributeDataTag("zh_CN").ID("MenuLangZHCN").Text("简体中文"),
                    //            F.MenuCheckBox().GroupName("MenuLang").AttributeDataTag("zh_TW").ID("MenuLangZHTW").Text("繁體中文"),
                    //            F.MenuCheckBox().GroupName("MenuLang").AttributeDataTag("en").ID("MenuLangEN").Text("English"),
                    //            F.MenuCheckBox().GroupName("MenuLang").AttributeDataTag("zh_UEY").ID("MenuLangZHUEY").Text("ئۇيغۇر تىلى")
                    //        ).Listener("checkchange", "onMenuLangCheckChange")
                    //    ),

                    //,F.MenuButton().ID("btnLoadingSelect").Text("加载动画").Listener("click", "onLoadingSelectClick")

                    )
                )
            )
        </div>
    </div>

    @(F.Panel().ID("mainPanel").ShowHeader(false).ShowBorder(false).Layout(LayoutType.Region).CssClass("mainpanel").IsViewPort(true)
        .Items(
            F.Panel().ID("sidebarRegion").CssClass("sidebarregion bgpanel").RegionPosition(Position.Left).Width(260).Layout(LayoutType.VBox).ShowBorder(false).ShowHeader(false).RegionSplit(true).RegionSplitIcon(false).RegionSplitWidth(3).RegionSplitTransparent(true)
                .Items(
                    F.Panel().ShowHeader(false).ShowBorder(false).CssClass("topregion").ID("topPanel").ContentEl("#sideheader"),
                    F.Panel().BoxFlex(1).Layout(LayoutType.Fit).ShowHeader(false).ShowBorder(true).CssClass("leftregion").ID("leftPanel")
                        .Items(
                            F.Tree().ID("treeMenu").ShowBorder(false).ShowHeader(false).EnableSingleClickExpand(true)
                                .Nodes((TreeNode[])ViewBag.TreeMenuNodes)
                        )
                ).Listener("splitdrag", "onSidebarSplitDrag"),
            F.Panel().ID("bodyRegion").CssClass("bodyregion").RegionPosition(Position.Center).Layout(LayoutType.VBox).ShowBorder(false).ShowHeader(false)
                .Items(
                    F.Panel().ID("topPanel").ShowHeader(false).ShowBorder(false).CssClass("topregion").ContentEl("#header"),
                    F.TabStrip().BoxFlex(1).ShowInkBar(true).InkBarPosition(InkBarPosition.Top).EnableTabCloseMenu(true).ShowBorder(true).RegionPosition(Position.Center).CssClass("centerregion").ID("mainTabStrip").ShowTabHeader(@ViewBag.CookieMainTabs=="multi")
                        .Tabs(
                            F.Tab().ID("tabHomepage").IFrameUrl(Url.Action("Main")).EnableIFrame(true).IconFont(IconFont._Home).Title("首页")
                        )
                        .Tools(

                            F.Tool().ID("toolRefresh").ToolTip("刷新本页").CssClass("tabtool").IconFont(IconFont._Refresh).Listener("click", "onToolRefreshClick")
                            //,F.Tool().ID("toolNewWindow").ToolTip("在新标签页中打开").CssClass("tabtool").IconFont(IconFont._NewTab).Listener("click", "onToolNewWindowClick")
                        )
                )
        )
    )
    @(F.Window().Hidden(true).EnableResize(true).EnableMaximize(true).EnableClose(true).Height(600).Width(1000).IsModal(true).ClearIFrameAfterClose(false).IFrameUrl(Url.Action("Edit","Home",new{ area = UrlAddress.AreaAdmin })).EnableIFrame(true).Title("个人编辑").ID("windowEdit"))
    @(F.Window().Hidden(true).EnableResize(true).EnableMaximize(true).EnableClose(true).Height(600).Width(1000).IsModal(true).ClearIFrameAfterClose(false).IFrameUrl(Url.Action("Themes")).EnableIFrame(true).Title("主题仓库").ID("windowThemeRoller"))
    @(F.Window().Hidden(true).EnableResize(true).EnableMaximize(true).EnableClose(true).Height(600).Width(1000).IsModal(true).ClearIFrameAfterClose(false).IFrameUrl(Url.Action("Loading")).EnableIFrame(true).Title("加载动画").ID("windowLoadingSelector"))
    @(F.HiddenField().ID("hfExamplesCount").Text(ViewBag.ExamplesCount))


    @{
        string cookieMenuStyle = (string)ViewBag.CookieMenuStyle;
        string cookieDisplayMode = (string)ViewBag.CookieDisplayMode;
        string cookieMainTabs = (string)ViewBag.CookieMainTabs;
        string cookieLang = (string)ViewBag.CookieLang;
        string cookieSearchText = (string)ViewBag.CookieSearchText;

        // 初始化左侧菜单
        Tree treeMenu = F.GetControl<Tree>("treeMenu");
        if (cookieMenuStyle == "tree")
        {
            treeMenu.HideHScrollbar = true;
            treeMenu.HideVScrollbar = true;
            treeMenu.ExpanderToRight = true;
            treeMenu.HeaderStyle = true;
            treeMenu.AllHeaderStyle = true;
        }

        // 初始化设置 - 显示模式
        SetCheckedMenuItem(F.GetControl<MenuButton>("MenuDisplayMode"), cookieDisplayMode);

        // 初始化设置 - 主选项卡标签
        SetCheckedMenuItem(F.GetControl<MenuButton>("MenuMainTabs"), cookieMainTabs);

        // 初始化设置 - 菜单样式
        SetCheckedMenuItem(F.GetControl<MenuButton>("MenuStyle"), cookieMenuStyle);

        // 初始化设置 - 语言
        //SetCheckedMenuItem(F.GetControl<MenuButton>("MenuLang"), cookieLang);
    }

}

@section script {
    <script type="text/javascript">
        // 本页面一定是顶层窗口，不会嵌在IFrame中
        if (top.window != window) {
            top.window.location.href = window.location.href;
        }
    </script>
    <script>
        var PARAMS = {
            mainPanel: 'mainPanel',
            mainTabStrip: 'mainTabStrip',
            treeMenu: 'treeMenu',
            sidebarRegion: 'sidebarRegion',
            btnCollapseSidebar: 'btnCollapseSidebar',
            tabHomepage: 'tabHomepage',
            windowSourceCode: 'windowSourceCode',
            windowThemeRoller: 'windowThemeRoller',
            windowLoadingSelector: 'windowLoadingSelector',
            //windowApplyTrial: 'windowApplyTrial',
            hfExamplesCount: 'hfExamplesCount',
            @*sourceUrl: '@Url.Content("~/Home/Source")',
            dashboardUrl: '@Url.Content("~/Block/Dashboard")',*@
            mainUrl: '@Url.Action("Main","Home")',
            processNewWindowUrl: function (url) {
                return url.replace(/\/Mobile\/\?file=/ig, '/Mobile/');
            }
        };

        // 点击主题仓库
        function onWindowEditClick(event) {
            var window = F('windowEdit');
            window.show();
        }
    </script>

    <script src="~/res/js/index.js?v@(GlobalConfig.ProductVersion)"></script>

}